package com.neuedu.studentmanage.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.neuedu.studentmanage.entity.Custodian;
import com.neuedu.studentmanage.entity.Pager;
import com.neuedu.studentmanage.entity.Result;
import com.neuedu.studentmanage.mapper.CustodianMapper;
import com.neuedu.studentmanage.service.CustodianService;

@Service
@Transactional
public class CustodianServiceImpl implements CustodianService {

	@Autowired
	private CustodianMapper custodianMapper;

	@Override
	public List<Custodian> findListByPager(Pager<Custodian> pager) {

		return custodianMapper.findListByPager(pager);
	}

	@Override
	public Integer findTotalByPager(Pager<Custodian> pager) {

		return custodianMapper.findTotalByPager(pager);
	}

	@Override
	public Result add(Custodian object) {
		Result result = new Result(false, "新增监护人信息失败");
		boolean ret = custodianMapper.add(object);
		if (ret) {
			result = new Result(true, "新增监护人信息成功");
		}
		return result;
	}

	@Override
	public Result edit(Custodian object) {
		Result result = new Result(false, "修改监护人信息失败");
		boolean ret = custodianMapper.edit(object);
		if (ret) {
			result = new Result(true, "修改监护人信息成功");
		}
		return result;
	}

	@Override
	public Result deleteByIds(List<Custodian> ids) {
		Result result = new Result(false, "删除监护人信息失败");
		boolean ret = custodianMapper.deleteByIds(ids);
		if (ret) {
			result = new Result(true, "删除监护人信息成功");
		}
		return result;
	}

	@Override
	public List<Custodian> findAll() {
		// TODO Auto-generated method stub
		return custodianMapper.findAll();
	}

}
